/*
 * SwingImageDelegate.h  0.4.0 / Nov 17, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef SWINGIMAGEDELEGATE_H
#define SWINGIMAGEDELEGATE_H

#include "Cute4jSwing.h"

// SwingImageDelegate Class. ---------------------------------------------------

/*!
 * \brief SwingImage Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT SwingImageDelegate
{
public: // native calls
  static jlong createImage(JNIEnv *env);
  static jlong createImage(JNIEnv *env, jobject obj, jbyteArray imageData,
                           jint lenght);
  static jobject createScaled(JNIEnv *env, jlong imagePointer, jint width,
                              jint height, jint hints, jstring format);
  static void initialize(JNIEnv *env, jclass cls);
public:
  static jobject newInstance(const QPixmap &pixmap, jstring format);
  static QPixmap *createDisabledPixmap(QPixmap *pm);
  static bool loadImage(JNIEnv *env, jbyteArray imageData, jint length,
                        QPixmap *pixmap);
private:
  static jclass sm_imageClass;
  static jmethodID sm_constructorMID;
  static jfieldID sm_widthFID;
  static jfieldID sm_heightFID;
};

// Macro Definition.  ----------------------------------------------------------

#define SWING_IMAGE (reinterpret_cast<QPixmap *>(imagePointer))

#endif // SWINGIMAGEDELEGATE_H
